(function(){
    publicParam.proposalsSize = 20;
    /**
    * 初始化
    */
	async function init(){
        if (!checkConnect()) return;
        var rtn = await loadManbers();
        if (rtn){
            if (!publicParam.proposals){
                setLoading(1);
                publicParam.proposalsNum = await numOfProposals();
                publicParam.isProposaAdmin = await isVoteAdmin();
                setLoading(0);
            }
            if(!publicParam.proposalsPage) publicParam.proposalsPage = 0;
            //如果提案数多于每页显示的数量，则显示分页按钮
            if(publicParam.proposalsNum>publicParam.proposalsSize){
                var param = {
                    total:publicParam.proposalsNum,
                    size:publicParam.proposalsSize,
                    current:publicParam.proposalsPage,
                    fn:load,
                };
                loadPage("/common/paging","paging",param);
            }
            load(publicParam.proposalsPage);
            getNode("refresh").onclick = ()=>{
                //强制刷新
                publicParam.proposals = null;
                publicParam.proposalsPage = 0;
                init();
            }
        }
    }
    /**
    * 为了分页每次载入一定量的提案
    */
	async function load(paging){
        setLoading(1);
        publicParam.proposalsPage = paging;
        publicParam.proposals = await getProposalsFromTo();
        loadPage("/common/proposalList","list");
        setLoading(0);
    }
	init();
})();